package com.ruoyi.web.controller.translation;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.translate.LanguageCodes;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.translat.domain.TencentTranslationDO;
import com.ruoyi.translat.domain.TencentTranslationIO;
import com.ruoyi.translat.service.TencentTranslationService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * @Title: 短剧版权链接 集数 分类 题材 供片日期 授权日期 售卖方 出品方 来源 授权方 版权链接
 * @author: WYJ
 * @date: 2025/10/9
 */

@RestController
@RequestMapping("/tencent/translation")
public class TencentTranslationController {

    private static final Logger log = LoggerFactory.getLogger(TencentTranslationController.class);

    @Autowired
    private TencentTranslationService tencentTranslationService;

    @PostMapping("/importData")
    public void importData(MultipartFile file, HttpServletResponse response) throws Exception {
        ExcelUtil<TencentTranslationIO> util = new ExcelUtil<TencentTranslationIO>(TencentTranslationIO.class);
        List<TencentTranslationIO> list = util.importExcel(file.getInputStream());
        List<TencentTranslationDO> reList = tencentTranslationService.TencentTranslationData(list);
        ExcelUtil<TencentTranslationDO> excelUtil = new ExcelUtil<TencentTranslationDO>(TencentTranslationDO.class);
        excelUtil.exportExcel(response,reList,"翻译导出");
    }

    @PostMapping("/str")
    public AjaxResult tencentTranslationStr(String title) {
        Map<String, String> map = tencentTranslationService.tencentTranslationStr(title);
        return AjaxResult.success(map);


    }



}
